package com.example.consumer.receiver;

import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

/**
 * 直连交换机和队列是一对一，配置多个消费者监听同一个队列，会轮询对消息进行消费，不会重复消费
 * 执行顺序是随机的?
 *
 * @author: qilongxin
 * @date: 2021/11/9 16:39
 */
@Component
public class DirectReceiver {

    @RabbitListener(queues = "testDirectQueue")
    public void consumer1(Object message) {
        System.out.println("第一个消费者消费消息：" + message.toString());
    }

    @RabbitListener(queues = "testDirectQueue")
    public void consumer2(Object message) {
        System.out.println("第二个消费者消费消息：" + message.toString());
    }

    @RabbitListener(queues = "testDirectQueue")
    public void consumer3(Object message) {
        System.out.println("第三个消费者消费消息：" + message.toString());
    }

    @RabbitListener(queues = "testDirectQueue")
    public void consumer4(Object message) {
        System.out.println("第四个消费者消费消息：" + message.toString());
    }

}
